/*
 * Copyright (c) Hisilicon Technologies Co., Ltd. 2020-2021. All rights reserved.
 * Description: 获取动态库中tdt接口函数的适配接口私有头文件.
 * Author: lzd
 * Create: 2020-06-10
 */

#ifndef HCCL_SRC_DLTDTFUNCTION_H
#define HCCL_SRC_DLTDTFUNCTION_H

#include <functional>
#include <mutex>
#include <hccl/hccl_types.h>
#include "base.h"
#include "tsd/tsd_client.h"

namespace hccl {
class DlTdtFunction {
public:
    virtual ~DlTdtFunction();
    static DlTdtFunction &GetInstance();
    HcclResult DlTdtFunctionInit();
    HcclResult DlTdtFunctionHeterogInit();

#ifndef HCCD
    std::function<tsd::TSD_StatusT(u32 deviceLogicId, u32 rankSize)> dlTsdOpen;
    std::function<tsd::TSD_StatusT(uint32_t deviceLogicId, int32_t type, uint64_t ptr)> dlTsdCapabilityGet;
#endif
    std::function<tsd::TSD_StatusT(u32 deviceLogicId, ProcOpenArgs *openArgs)> dlTsdProcessOpen;
    std::function<tsd::TSD_StatusT(u32 deviceLogicId, ProcStatusParam *closeList, u32 listSize)> \
        dlProcessCloseSubProcList;

protected:
private:
    void *handle_;
    std::mutex handleMutex_;
    DlTdtFunction(const DlTdtFunction&);
    DlTdtFunction &operator=(const DlTdtFunction&);
    DlTdtFunction();
};
}  // namespace hccl

#endif  // HCCL_SRC_DLTDTFUNCTION_H
